<?php

namespace app\models;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use app\models\Total;

/**
 * TotalSearch represents the model behind the search form about `app\models\Total`.
 */
class TotalSearch extends Total
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['t_id', 'jt_num', 'yey_num', 'yey_id', 't_num', 's_num', 'p_num', 'a_num', 'img_size', 'v_size', 'mes_num', 'p_a_num'], 'integer'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = Total::find();

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        $query->andFilterWhere([
            't_id' => $this->t_id,
            'jt_num' => $this->jt_num,
            'yey_num' => $this->yey_num,
            'yey_id' => $this->yey_id,
            't_num' => $this->t_num,
            's_num' => $this->s_num,
            'p_num' => $this->p_num,
            'a_num' => $this->a_num,
            'img_size' => $this->img_size,
            'v_size' => $this->v_size,
            'mes_num' => $this->mes_num,
            'p_a_num' => $this->p_a_num,
        ]);

        return $dataProvider;
    }
}
